<template>
  <div>
    <h1>Table</h1>
    <VxeTable
      border
      :data="tableData"
      :merge-cells=mergeCells
      :menu-config="menuConfig"
      show-footer
      :footer-data="footerData"
      >
      <VxeColumn type="seq" width="70"></VxeColumn>
      <VxeColumn field="name" title="Name"></VxeColumn>
      <VxeColumn field="sex" title="Sex"></VxeColumn>
      <VxeColumn field="age" title="Age"></VxeColumn>
      <VxeColumn field="address" title="Address" show-overflow></VxeColumn>
    </VxeTable>
  </div>
</template>

<script lang="ts" setup>
import { ref, defineComponent } from 'vue'
import type { VxeTablePropTypes } from '@vben/plugins/vxe-table';
// // 组件的其他代码
// });
// export type { VxeGridListeners, VxeGridProps, VxeTableInstance } from '@vben/vxe-table';
// import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
defineOptions({
  // name 作为一种规范最好必须写上并且和路由的name保持一致
  name: "Table"
});
interface RowVO {
  id: number
  name: string
  role: string
  sex: string
  age: number
  address: string
}
const menuConfig: VxeTablePropTypes.MenuConfig<RowVO> = {
      header: {
        options: [
          [
            { code: 'myExportMenu', name: '导出数据' }
          ]
        ]
      },
      body: {
        options: [
          [
            { code: 'myExportMenu', name: '导出数据' },
            { code: 'myPrintMenu', name: '打印' },
            { code: 'myLinkMenu', name: '打开官网' }
          ]
        ]
      },
      footer: {
        options: [
          [
            { code: 'myLinkMenu', name: '打开官网' }
          ]
        ]
      }
    }
    const footerData: VxeTablePropTypes.FooterData = [
      { seq: '合计', num: 21 }
    ]
const tableData = ref<RowVO[]>([
  { id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },
  { id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
  { id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
  { id: 10004, name: 'Test4', role: 'Designer', sex: 'Women', age: 24, address: 'Shanghai' }
])

const mergeCells = ref<VxeTablePropTypes.MergeCells>([
  { row: 1, col: 1, rowspan: 3, colspan: 1 },
  { row: 1, col: 3, rowspan: 2, colspan: 1 }
])
</script>
